package com.eudon.design_pattern.creational.singleton;

/**
 * @author eudon
 * @description 饿汉单例模式 second
 * @date 2025/8/24
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class EagerSingletonS {
    private static final EagerSingletonS INSTANCE;

    static {
        //静态代码块的好处就是，如果这个单例需要额外的参数进行实例化，那在这里可以进行复杂的处理或者异常相关控制
        try {
            INSTANCE = new EagerSingletonS();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private EagerSingletonS() {

    }
    public static EagerSingletonS getInstance() {
        return INSTANCE;
    }
}
